#include "CEgg.h"

CEgg::CEgg(void) {
	img = NULL;
	direction = false;
	speed = D3DXVECTOR2(0,5);
	width = 0; 
	height = 0;
	center = D3DXVECTOR3(0,0,0);
}

CEgg::~CEgg(void) {

}

void CEgg::Init(CContent *content,D3DXVECTOR2 pos,string path) {
	this->img = content->LoadTexture(path.c_str());
	this->position = D3DXVECTOR2(pos.x,108);
	this->speed = D3DXVECTOR2(0,5);
	this->height = 88;
	this->width = 82;
	this->direction = true;
	this->rect.top = 0;
	this->rect.left = 0;
	this->rect.right = 82;
	this->rect.bottom = 88;
}

void CEgg::Update(float gameTime) {
	if(this->position.y < SCREEN_HEIGHT - this->height) {
		this->position.y += this->speed.y;
	}
}

void CEgg::Render(CGraphic *graphic) {
	graphic->DrawTexture(this->img,this->center,this->position,D3DCOLOR_XRGB(255,255,255));
}

bool CEgg::CheckCollisions(D3DXVECTOR2 pos) {
	return ((this->position == pos) ? true : false);
}

void CEgg::ShutDown(void) {
	if(img) {
		img->Release();
	}
}
